VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsOptions"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "RVB_UniqueId" ,"3521FD23035C"
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

Public Property Get PhoneEntry(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    PhoneEntry = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "PhoneEntry")
End Property

Public Property Let PhoneEntry(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "PhoneEntry", vData, REG_SZ
End Property

Public Property Get ShareName(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    ShareName = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "ShareName")
End Property

Public Property Let ShareName(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "ShareName", vData, REG_SZ
End Property

Public Property Get UserName(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    UserName = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "UserName")
End Property

Public Property Let UserName(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "UserName", vData, REG_SZ
End Property

Public Property Get Password(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    Password = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Password")
End Property

Public Property Let Password(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Password", vData, REG_SZ
End Property

Public Property Get Compress(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    Compress = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Compress")
End Property

Public Property Let Compress(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Compress", vData, REG_SZ
End Property

Public Property Get Transfer(strDestination As String) As String
'used when retrieving value of a property, on the right side of an assignment.
    Transfer = GetSettingC("Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Transfer")
End Property

Public Property Let Transfer(strDestination As String, ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDestination, "Transfer", vData, REG_SZ
End Property

Public Property Get FileNumber() As String
'used when retrieving value of a property, on the right side of an assignment.
    FileNumber = GetSettingC("Software\Mindkey Software Solutions\SendKey\Source", "FileNumber")
    If FileNumber = "" Then
      FileNumber = "0"
    End If
End Property

Public Property Let FileNumber(ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Source", "FileNumber", vData, REG_SZ
End Property

Public Property Get DeleteFiles() As String
'used when retrieving value of a property, on the right side of an assignment.
    DeleteFiles = GetSettingC("Software\Mindkey Software Solutions\SendKey\Source", "DeleteFiles")
End Property

Public Property Let DeleteFiles(ByVal vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Source", "DeleteFiles", vData, REG_SZ
End Property

Public Property Get MoveFolder() As String
'used when retrieving value of a property, on the right side of an assignment.
    MoveFolder = GetSettingC("Software\Mindkey Software Solutions\SendKey\Source", "MoveFolder")
End Property

Public Property Let MoveFolder(ByVal vData As String)
   'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Source", "MoveFolder", vData, REG_SZ
End Property

Public Property Get BranchCode() As String
'used when retrieving value of a property, on the right side of an assignment.
    BranchCode = GetSettingC("Software\Mindkey Software Solutions\SendKey\Source", "BranchCode")
End Property

Public Property Let BranchCode(ByVal vData As String)
   'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Source", "BranchCode", vData, REG_SZ
End Property

Public Property Get LogFolder() As String
'used when retrieving value of a property, on the right side of an assignment.
    LogFolder = GetSettingC("Software\Mindkey Software Solutions\SendKey\Source", "LogFolder")
End Property

Public Property Let LogFolder(ByVal vData As String)
   'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\Source", "LogFolder", vData, REG_SZ
End Property

'##ModelId=3521FD24019A
Private Function GetSettingC(strKeyName As String, strValueName As String) As String
'Purpose
'*******
'Gets the value a certain registry key

On Error GoTo GetSettingsCFix

'Variables
'*********
    Dim lngRetVal As Long           'Result of the API functions
    Dim hKey As Long                'Handle of the opened key
    Dim szBuffer As String          'Setting of the queried value
    Dim lngBuffSize As Long
    
'Code
'****
    'Create the buffer
    szBuffer = Space(255)
    lngBuffSize = 255
    
    'Open the specified registry key
    lngRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, KEY_ALL_ACCESS, hKey)
    If lngRetVal <> ERROR_SUCCESS Then
        'MsgBox "Registry key or Value Name doesn't exist", vbExclamation
        Exit Function
    End If
    
    'Read the opened registry key
    lngRetVal = RegQueryValueEx(hKey, strValueName, 0, 0, szBuffer, lngBuffSize)
    
    GetSettingC = Trim(Left(szBuffer, lngBuffSize - 1))
    
    'Close the registry key
    RegCloseKey (hKey)

    Exit Function
    
GetSettingsCFix:
    MsgBox "clsOptions.GetSettingsC: " & Err.Description
    
End Function


'##ModelId=3521FD2A029E
Private Sub SaveSettingC(strKeyName As String, strValueName As String, varValueSetting As Variant, lngValueType As Long)
'Purpose
'*******
'Set the value of a Registry key if it exist.
'if the registry key doesn't exist it will be created

On Error GoTo SaveSettingsCFix

'Variables
'*********
    Dim hKey As Long            'Handle to the key
    Dim lngRetVal As Long       'Result of API functions
    Dim SA As SECURITY_ATTRIBUTES
    Dim create As Long

'Code
'****
    'Open or Ceate the registry key
    lngRetVal = RegCreateKeyEx(HKEY_LOCAL_MACHINE, strKeyName, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, SA, hKey, create)
    If lngRetVal <> ERROR_SUCCESS Then
        MsgBox "An error occured while trying to set the registry key", vbExclamation
        Exit Sub
    End If
    
    'Set or create a registry value
    lngRetVal = RegSetValueEx(hKey, strValueName, 0, lngValueType, varValueSetting, CLng(Len(varValueSetting) + 1))
        
    RegCloseKey (hKey)
    
    Exit Sub
    
SaveSettingsCFix:
    MsgBox "Options.SavesSettingsC: ", Err.Description
    
End Sub
                     
Public Function EncryptString(strString As String) As String
'Purpose
'*******

'Variables
'*********
    Dim i As Integer
    Dim strTemp As String
    
'Code
'****
    On Error GoTo EncryptStringFix
           
    For i = 1 To Len(strString)
        strTemp = strTemp & Chr(Asc(Mid(strString, i, 1)) + 20)
    Next i
        
    EncryptString = strTemp
        
    Exit Function

EncryptStringFix:
   HandleError Err.Description, "EncryptString"
   
End Function

Public Function DecryptString(strString As String) As String
'Purpose
'*******

'Variables
'*********
    Dim i As Integer
    Dim strTemp As String
    
'Code
'****
    On Error GoTo EncryptStringFix
           
    For i = 1 To Len(strString)
        strTemp = strTemp & Chr(Asc(Mid(strString, i, 1)) - 20)
    Next i
                                          
    DecryptString = strTemp
    
    Exit Function

EncryptStringFix:
   HandleError Err.Description, "EncryptString"
   
End Function

'##ModelId=3521FD2F003C
Private Sub HandleError(strErrDescr As String, strSubName As String)

'Displays Error Description and Sub Name if Error occures within Methods

  MsgBox strSubName & ": " & strErrDescr, vbSystemModal

End Sub
Public Function GetAllDestinationsFromReg() As String
'this function retrieves all the destinations and puts them into a comma delimeted string and passes
'that string out.
Dim lngRetVal As Long
Dim lpName As String
Dim lpcNameBufLen As Long
Dim lngKeyIndex As Long
Dim lngEnumReturn As Long
Dim lpFileTime As FILETIME
Dim strNodeList As String
Dim hKey As Long
Dim lpNameTemp As String
Dim i As Long

On Error GoTo GetAllDestinationsFromReg_FIX

'open the key to enumerate thru
lngRetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\Mindkey Software Solutions\SendKey\Destinations", 0, KEY_ALL_ACCESS, hKey)

If lngRetVal <> ERROR_SUCCESS Then
   'an error has occured
   GoTo GetAllDestinationsFromReg_FIX
End If

'initilize the buffer
lpcNameBufLen = 255
lpName = Space(lpcNameBufLen)
   
'loop thru the nodes when done returns ERROR_NO_MORE_ITEMS
Do While RegEnumKeyEx(hKey, lngKeyIndex, lpName, lpcNameBufLen, 0, "", 0, lpFileTime) <> ERROR_NO_MORE_ITEMS
   'Remove the trailing null
   lpName = RTrim(lpName)
   lpNameTemp = Left$(lpName, Len(lpName) - 1)
   strNodeList = strNodeList & Trim(lpNameTemp) & ","
   'increment the index
   lngKeyIndex = lngKeyIndex + 1
   'initilize the buffer
   lpcNameBufLen = 255
   lpName = Space(lpcNameBufLen)
Loop

'drop the trailing comma
If strNodeList <> "" Then
  strNodeList = Left$(strNodeList, Len(strNodeList) - 1)
End If

'pass out the destinations
GetAllDestinationsFromReg = strNodeList
Exit Function

GetAllDestinationsFromReg_FIX:
   If Err.Number <> 0 Then
     MsgBox Err.Description & " ," & Err.Number
   End If
End Function

'#BM - Send emails to this group if there is any problem or update
Public Property Get FTPEmail() As String
'used when retrieving value of a property, on the right side of an assignment.
    FTPEmail = GetSettingC("Software\Mindkey Software Solutions\SendKey\", "FTPEmail")
End Property

'#BM - Send emails to this group if there is any problem or update
Public Property Let FTPEmail(vData As String)
'used when setting the value of a property
    SaveSettingC "Software\Mindkey Software Solutions\SendKey\", "FTPEmail", vData, REG_SZ
End Property

